import React from 'react';
import {Route, Redirect} from 'react-router-dom'
import {isAuthenticated} from "../../utils/session";

const RequireUnAuthRoute = ({component: Component, ...rest}) => (

    <Route
        {...rest}
        render={(props) => {
            return !!isAuthenticated() ? (
                <Redirect to={{
                    pathname: '/',
                    state: {from: props.location}
                }}/>
            ) : (
                <Component {...props}/>
            )
        }}
    />
);


export default RequireUnAuthRoute;
